#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAXN 100010
#define db double
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define mdI int mid=(l+r)>>1
#define pbI push_back
#define ll long long
#define MOD 998244353
#define lowbit(x) x&(-x)
#define rep(a,b,c) for(int a=b;a<=c;a++)
void chmi(ll &x,ll y){x=min(x,y);}
void chmx(ll &x,ll y){x=max(x,y);}
int qread(){
    char o=0;int f=1,x=0;
    for(;!isdigit(o);o=getchar())if(o=='-')f=-1;
    for(;isdigit(o);o=getchar())x=x*10+(o-'0');
    return f*x;
}
ll qp(ll a,ll b,ll c=MOD){ll rs=1,bs=a;while(b){if(b&1)rs=rs*bs%c;bs=bs*bs%c;b>>=1;}return rs;}
bool FLA;
int n,m,l,v;
int d[MAXN],V[MAXN],a[MAXN],p[MAXN];
int L[MAXN],R[MAXN],dp[MAXN];
vector<int>vec[MAXN];
#define eps 1e-9
bool FLB;
signed main(){
    cerr<<((&FLB)-(&FLA))/1024.0/1024.0<<endl;
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;cin>>T;
    while(T--){
        cin>>n>>m>>l>>v;
        memset(d,0,sizeof(d));memset(V,0,sizeof(V));
        memset(a,0,sizeof(a));memset(p,0,sizeof(p));
        rep(i,1,n)d[i]=qread(),V[i]=qread(),a[i]=qread();
        rep(i,1,m)p[i]=qread();
        sort(p+1,p+1+m);
        int ans1=0;
        rep(i,1,n){
            db L1=0,R1=-1;
            db wh=d[i]+(v*v-V[i]*V[i])/2.0/a[i];
            bool A=0;
            if(a[i]>0){L1=wh,R1=l;if(L1<d[i])A=1,L1=d[i];}
            else if(a[i]<0){L1=d[i],R1=wh;}
            else{if(V[i]>v)L1=d[i],R1=l;}
            L[i]=lower_bound(p+1,p+1+m,ceil(L1))-p;
            R[i]=upper_bound(p+1,p+1+m,floor(R1))-p-1;
            if(a[i]>0&&!A&&fabs(p[L[i]]-L1)<eps){L[i]++;}
            if(a[i]<0&&fabs(p[R[i]]-R1)<eps){R[i]--;}
            if(R[i]==0||L[i]>m)continue;
            chmi(L[i],m);chmx(L[i],1);
            chmi(R[i],m);chmx(R[i],1);
            if(L[i]<=R[i]){ans1++;vec[R[i]].pbI(L[i]);}
        }
        memset(dp,0x3f,sizeof(dp));
        int nd=0;dp[0]=0;
        set<pii>S;S.insert(mp(0,0));
        rep(i,1,m){
            for(auto it:vec[i]){chmx(nd,it);}
            if(nd==0)dp[i]=dp[i-1];
            else{while(!S.empty()&&(*S.begin()).se<nd-1)S.erase(S.begin());dp[i]=(*S.begin()).fi+1;}
            S.insert(mp(dp[i],i));
        }
        cout<<ans1<<" "<<m-dp[m]<<endl;
        rep(i,1,n)L[i]=R[i]=0;
        rep(i,1,m)vec[i].clear();
    }
}
